<?php
$kcNum = $_REQUEST["kcNum"];
$kcName = $_REQUEST["kcName"];
$kcTime = $_REQUEST["kcTime"];
$action = $_REQUEST["action"];
echo "$kcNum";
echo "$kcName";
echo "$kcTime";
echo "$action";

include_once("conn.php");
//3.运行sql语句，执行增、删、改、查
if($action=="add"){
    $sql1 = "insert into `课程`(课程编号,课程名称,学习时长)value('{$kcNum}','{$kcName}','{$kcTime}')";
    header("Refresh:1;url=kecheng-input.php");
    $str = "数据插入成功";
}else if($action=="update"){
    $sql1 = "update 课程 set 课程编号='{$kcNum}',课程名称='{$kcName}',学习时长='{$kcTime}' where 课程编号='{$kcNum}'";
    header("Refresh:1;url=kecheng-list.php");
    $str = "数据修改成功";
}else{
    die("请正确输入参数");
}
$result = mysqli_query($conn,$sql1);
if($result){
    echo "<script>alert('$str')</script>";
    // header("Refresh:1;url=kecheng-input.php");
}else{
    echo "<script>alert('数据插入失败')</script>";
}
//4.关闭连接，释放资源
mysqli_close($conn);

?>